﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Web;
using System.Web.UI;
using System.Web.UI.WebControls;

namespace WebApp
{
   public partial class _Default : System.Web.UI.Page
   {
      protected override void OnInit(EventArgs e)
      {
         base.OnInit(e);

         // Create datasource
         ObjectDataSource ods = new ObjectDataSource(
            "WebApp.ServiceReference.ServiceClient", "GetPersonList");

         ods.SelectParameters.Add(
            new ControlParameter("count", TypeCode.Int32, TextBox1.ID, "Text"));
         ods.SelectParameters["count"].DefaultValue = "10";

         form1.Controls.Add(ods);

         // Init grid view
         gridView.DataSource = ods;


         // Init validator
         reValidator.ControlToValidate = TextBox1.ID;
         reValidator.ErrorMessage = "Invalid number!";
         reValidator.SetFocusOnError = true;
         reValidator.ValidationExpression = @"\d*";
         reValidator.ForeColor = System.Drawing.Color.FromArgb(0xCC0000);
      }

      protected void Page_Load(object sender, EventArgs e)
      {
         gridView.DataBind();
      }
   }
}